//
//  SexTableViewCell.m
//  帮惠Mall
//
//  Created by reew on 2017/9/22.
//  Copyright © 2017年 reew. All rights reserved.
//

#import "SexTableViewCell.h"
@implementation SexTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _femaleSelect = NO;
    _maleSelect= NO;
    [self setButtonBorderColor:[UIColor grayColor] button:_maleBtn];
    [self setButtonBorderColor:[UIColor grayColor] button:_femaleBtn];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)selectMan:(UIButton *)sender {
    
    if (!_maleSelect) {
        [self setButtonBorderColor:[UIColor redColor] button:sender];
    }else{
        [self setButtonBorderColor:[UIColor grayColor] button:sender];
    }
    _maleSelect = !_maleSelect;
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectSexButtonWithMale:female:)]) {
        [self.delegate didSelectSexButtonWithMale:_maleSelect female:_femaleSelect];
    }
    
}
- (IBAction)selctWomen:(UIButton *)sender {
    
    if (!_femaleSelect) {
        [self setButtonBorderColor:[UIColor redColor] button:sender];
    }else{
        [self setButtonBorderColor:[UIColor grayColor] button:sender];
    }
    _femaleSelect = !_femaleSelect;
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectSexButtonWithMale:female:)]) {
        [self.delegate didSelectSexButtonWithMale:_maleSelect female:_femaleSelect];
    }
    
}
- (void)setButtonBorderColor:(UIColor *)color button:(UIButton *)sender{
    [sender.layer setBorderColor:color.CGColor];
    [sender.layer setMasksToBounds:YES];
    [sender.layer setBorderWidth:1];
}
@end
